package com.bootcamp.s3_1013.database._1019_JBUtils;

import com.bootcamp.s3_1013.database.utils.DruidUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @program: myClassCode
 * @description: various connection pool
 * @author: Keyu Li
 * @create: 2021-10-19 10:53
 **/

public class Demo1_Druid {
    public static void main(String[] args) {
        Connection connection = DruidUtils.getConnection();
        try {
            PreparedStatement preparedStatement = connection.prepareStatement("select * from emp where empno=?");
            preparedStatement.setInt(1,1);
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()){
                String ename = resultSet.getString("ename");
                String job = resultSet.getString("job");
                System.out.println(ename+", "+job);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
